/*
 * @brief
 * @author li yong (DogLee)
 * @email 20162439@qq.com
 * @version 1.0
 * @date 2018-08-03 11:21:52
 */
#ifndef LOGAPPENDERFILE_H
#define LOGAPPENDERFILE_H

#include "ilogappender.h"

#include <QFile>
#include <QTimer>

class LogAppenderFile : public ILogAppender
{
    Q_OBJECT
public:
    LogAppenderFile();

    virtual ~LogAppenderFile();

    virtual void append(const DebugMessage &message);

    void setLogPath(const QString &path);

    void setLogName(const QString &name);

    virtual void dump() {onDump();}

private slots:
    void onDump();

private:
    bool isFull() const;

    void rotate();


private:
    QList<DebugMessage> messages;
    QFile logFile;
    QString logPath;
    QString logFileName;
    QTimer* timer;
};

#endif // LOGAPPENDERFILE_H
